package fr.utbm.lo53;

import android.app.Activity;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;


public class Settings {
	private static Settings instance = null;
	private SharedPreferences SharedPreferences;
	private SharedPreferences.Editor Editor;
	
	protected Settings(Activity MyActivity)
	{
		SharedPreferences = PreferenceManager.getDefaultSharedPreferences(MyActivity);
		Editor = SharedPreferences.edit();
	}
	
	// Singleton Pattern
	public static Settings getInstance()
	{
		return instance ;
	}
	
	// Singleton Pattern
	public static Settings createInstance(Activity MyActivity)
	{
		if(instance == null)
		{
			instance = new Settings(MyActivity);
		}
		return instance;
	}
	
	public boolean hasIp()
	{
		return !getIp().equals("");
	}
	
	public String getIp()
	{
		return SharedPreferences.getString("ips_ip", "");
	}	
	public void setIp(String ip)
	{
		Editor.putString("ips_ip", ip);
		Editor.commit();
	}
	public boolean hasPort()
	{
		return !getPort().equals("");
	}
	public String getPort()
	{
		return SharedPreferences.getString("ips_port", "");
	}	
	public void setPort(String port)
	{
		Editor.putString("ips_port", port);
		Editor.commit();
	}
}

